package com.zzl.finance.data.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.zzl.apidoc.annotation.ApidocModel;
import com.zzl.apidoc.annotation.ApidocModelProperty;
import com.zzl.finance.data.constant.BusinessModeEnum;
import com.zzl.finance.data.constant.FinanceBusinessTypeEnum;
import com.zzl.finance.data.constant.SealTypeEnum;
import com.zzl.finance.data.constant.StringConstant;
import com.zzl.general.common.utils.DoubleSerialize;
import com.zzl.general.common.utils.DoubleToPercentSerialize;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * 金融产品
 *
 * @author gull
 * @date 2021-12-22 19:40:27
 */
@Data
@ApidocModel
public class FinancialProductDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApidocModelProperty(description = "主键")
    private Integer id;
    @ApidocModelProperty(description = "金融机构id")
    private Integer financeInstitutyId;
    @ApidocModelProperty(description = "金融产品")
    private String productName;

    @JsonSerialize(using = DoubleToPercentSerialize.class)
    @ApidocModelProperty(description = "融资利率")
    private Double annualizedInterestRate;
    @ApidocModelProperty(description = "融资利率是否年化,0：否，1:是")
    private Integer isAnnualizedInterestRate;
    @ApidocModelProperty(description = "业务方式 1 无追索权")
    private Integer businessMode;
    @ApidocModelProperty(description = "业务方式 1 无追索权")
    private String businessModeName;
    @ApidocModelProperty(description = "金融机构")
    private String instinctyName;


    @ApidocModelProperty(description = "产品标识")
    private String productCode;
    @ApidocModelProperty(description = "开户行行号")
    private String financeDepositBankNo;
    @ApidocModelProperty(description = "金融产品计算脚本")
    private String scriptCode;
    @ApidocModelProperty(description = "产品描述")
    private String description;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApidocModelProperty(description = "创建时间", validate = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApidocModelProperty(description = "修改时间", validate = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;


    @JsonSerialize(using = DoubleToPercentSerialize.class)
    @ApidocModelProperty(description = "平台服务费率")
    private Double platServiceRate;

    public Double getPlatServiceRate() {
        if (null == platServiceRate) {
            platServiceRate = StringConstant.PLAT_SERVICE_RATE;
        }
        return platServiceRate;
    }

    @ApidocModelProperty(description = "平台服务费率是否年化，0 否，1 是")
    private Integer isAnnualizedPlatServiceRate;
    @ApidocModelProperty(description = "宽限期是否计息，0 否，1 是")
    private Integer isGraceCost;
    @ApidocModelProperty(description = "宽限天数")
    private Integer graceDays;

    @ApidocModelProperty(description = "用章类型 1 公章")
    private Integer sealType;
    @ApidocModelProperty(description = "业务类型 1 公开型")
    private Integer businessType;


    @ApidocModelProperty(description = "用章类型 1 公章")
    private String sealTypeName;
    @ApidocModelProperty(description = "业务类型 1 公开型")
    private String businessTypeName;

    public String getSealTypeName() {
        return SealTypeEnum.getValue(sealType);
    }

    public String getBusinessModeName() {
        return BusinessModeEnum.getValue(businessMode);
    }

    public String getBusinessTypeName() {
        return FinanceBusinessTypeEnum.getValue(businessType);
    }

    @ApidocModelProperty(description = "金融机构主键")
    private Integer instinctyId;
    @ApidocModelProperty(description = "金融机构代码")
    private String institutyCode;
    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "可融资金额")
    private Double financingAmount;
    @ApidocModelProperty(description = "额度编号")
    private String creditNo;
    @ApidocModelProperty(description = "融资额度id")
    private Integer supplierCreditId;
}
